home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 10, No. 07 (1989-07)(MindCraft Publishing)(Side A)[a].zip
/
Nibble Volume 10, No. 07 (1989-07)(MindCraft Publishing)(Side A)[a].po
/
SYS.DEV.ASM.txt
< prev
next >
Wrap
Text File
|
1996-12-24
|
25KB
|
710 lines
****************************************
* *
* System Devices NDA *
* APW Assembler Source Listing *
* by Sandy Mossberg *
* *
* Copyright (C) 1989 *
* by MicroSPARC, Inc. *
* Concord, MA 01742 *
* *
****************************************
mcopy sys.dev.mac ;macro file
keep sys.dev ;convert to NDA with FILETYPE command
*****************************************************************
*
NDA_Header start
*
* NDA header:
*
*****************************************************************
dc i4'NDA_Open' ;ptr to open routine
dc i4'NDA_Close' ;ptr to close routine
dc i4'NDA_Action' ;ptr to action routine
dc i4'NDA_Init' ;ptr to initialization routine
dc i2'60' ;period: run every 1 second
dc i2'%1111111111010111' ;event mask: ignore key-down events
dc c'--' ;place-holders (length)
dc c'System Devices\' ;text of name + name terminator
dc c'H--' ;place-holders (menu ID)
dc i1'0' ;end of name byte
end
*****************************************************************
*
NDA_Open start
*
* Open NDA if it is closed:
*
* Entry: 1-3,s = return address; 4,s = B-reg; 5-8,s = space for window pointer.
*
* Exit: 1-4,s = window pointer.
*
*****************************************************************
using Globals
phb ;save entry data bank
phk ;equate data bank to program bank
plb
lda OpenFlag
bne Done ;NDA already open so exit
jsr GetDevices ;create tables of devices/descriptions
jsr SetWindSize ;customize window size
PushLong #0 ;create NDA window
PushLong #WindowRec
_NewWindow
plx ;save ptr to NDA window's GrafPort
pla
stx WindowPtr
sta WindowPtr+2
sta 7,s ;put window ptr on stack for Desk
txa ; Manager after PLB and RTL
sta 5,s ; instructions executed
PushLong WindowPtr ;mark NDA window as system window
_SetSysWindow
lda #-1 ;signal that NDA is open
sta OpenFlag
Done plb ;restore entry data bank
rtl
end
*****************************************************************
*
NDA_Init start
*
* Initialize NDA startup and shutdown:
*
* Entry: A = zero = DeskShutDown; A = nonzero = DeskStartUp.
*
*****************************************************************
tax ;test A-reg
beq NDA_Close ;close NDA
rtl ;opening NDA requires no action
end
*****************************************************************
*
NDA_Close start
*
* Close NDA if it is open:
*
*****************************************************************
using Globals
phb ;save entry data bank
phk ;equate data bank to program bank
plb
lda OpenFlag
beq Done ;NDA already closed
PushLong WindowPtr ;close NDA window
_CloseWindow
stz OpenFlag ;signal that NDA is closed
Done plb ;restore entry data bank
rtl
end
*****************************************************************
*
NDA_Action start
*
* Handle the designated action:
*
* Entry: A = action code; X,Y = pointer to event record or menu IDs.
*
*****************************************************************
phb ;save entry data bank
phy ;save ptr to event record or menu IDs
phx
phk ;equate data bank to program bank
plb
asl a ;index table of 2-byte entries
tax
jsr (ActionTable,x) ;perform action
plx ;restore ptr to event record or menu IDs
ply
plb ;restore entry data bank
rtl
;................................................................
;
; NDA_Action data:
;
ActionTable anop ;action table
dc i2'DoNothing' ;0 = no action
dc i2'DoEvent' ;1 = event action
dc i2'DoRun' ;2 = run action
dc i2'DoNothing' ;3 = cursor action
dc i2'DoNothing' ;4 = menu action
dc i2'DoNoEdit' ;5 = undo action
dc i2'DoNoEdit' ;6 = cut action
dc i2'DoNoEdit' ;7 = copy action
dc i2'DoNoEdit' ;8 = paste action
dc i2'DoNoEdit' ;9 = clear action
end
*****************************************************************
*
DoNoEdit start
*
* Take no edit action but pretend you did:
*
*****************************************************************
lda #-1 ;signal that action handled
DoNothing entry ;just do nothing
rts
end
*****************************************************************
*
DoRun start
*
* Perform display action when time period has expired:
*
*****************************************************************
using Globals
PushLong #0 ;save entry GrafPort on stack
_GetPort
PushLong WindowPtr ;activate NDA GrafPort
_SetPort
jsr ShowDevices ;display device names and descriptions
_SetPort ;restore entry GrafPort
rts
end
*****************************************************************
*
DoEvent start
*
* Handle event action:
*
* Entry: 5,s = pointer to event record.
*
*****************************************************************
using Globals
What equ $05 ;location of ptr to event record
phd ;save entry direct page
tsc ;align direct page with stack
tcd
lda [What] ;get "what" code of event record
cmp #9
bcs Done ;unsupported code found
asl a ;index table of 2-byte entries
tax
jsr (EventTable,x) ;handle event
Done pld ;restore entry direct page
rts
;................................................................
;
; DoEvent data:
;
EventTable anop ;event table
dc i2'DoNothing' ;0 = null event
dc i2'DoNothing' ;1 = mouse-down event
dc i2'DoNothing' ;2 = mouse-up event
dc i2'DoNothing' ;3 = key-down event
dc i2'DoNothing' ;4 = reserved event
dc i2'DoNothing' ;5 = auto-key event
dc i2'DoUpdate' ;6 = window update event
dc i2'DoNothing' ;7 = reserved event
dc i2'DoNothing' ;8 = window activate event
end
*****************************************************************
*
DoUpdate start
*
* Update NDA window:
*
*****************************************************************
using Globals
PushLong WindowPtr
_BeginUpdate
jsr ShowDevices
PushLong WindowPtr
_EndUpdate
rts
end
*****************************************************************
*
GetDevices start
*
* Create table of device names and table of pathnames/descriptions:
*
*****************************************************************
using Globals
Ptr equ $00 ;temporary ptr
stz devNum ;prepare for sequential device numbers
GD01 lda devNum ;create index to device name table
asl a ; and device info table
asl a
asl a
asl a
asl a
sta TableIndex
inc devNum ;bump device number
lda devNum ;allow no more than 16 devices
cmp #17
bcs GD02
_DInfoGS DInfoParm ;get device info
bcc GD03 ;no error
GD02 brl Done ;finished with device list
GD03 lda devNameStr ;convert GS/OS string at devNameStr
xba ; to P-string at devNameStr+1
sta devNameStr
PushLong #devNameStr+1 ;copy name string to device name table
ldx #^DevNameTbl
clc
lda #DevNameTbl
adc TableIndex
bcc GD04
inx
GD04 phx
pha
PushWord #0
lda devNameStr+1
and #$FF
inc a
pha
_BlockMove
lda charistics ;get device characteristics
and #$0080 ;isolate block device bit
beq GD08 ;device not a block device
lda devNameStr ;convert P-string at devNameStr+1
xba ; to GS/OS string at devNameStr
sta devNameStr ; for class 1 GS/OS call
_VolumeGS VolumeParm ;get volume info
bcc GD05 ;no error
PushLong #NoVolStr ;copy [volume not found] to
lda NoVolStr ; device info table
bra GD06
GD05 lda volNameStr ;convert GS/OS string at volNameStr
xba ; to P-string at volNameStr+1
sta volNameStr
shortm ;change semicolon separator
lda #'/' ; to slash separator
sta volNameStr+2
longm
PushLong #volNameStr+1 ;copy volume name string to
lda VolNameStr+1 ; device info table
GD06 and #$FF
inc a
sta StrLen
ldx #^DevInfoTbl
clc
lda #DevInfoTbl
adc TableIndex
bcc GD07
inx
GD07 phx
pha
PushLong StrLen
_BlockMove
brl GD01 ;loop back for another device
GD08 lda Ptr ;copy device ID string to
sta DPSave ; device info table
lda Ptr+2
sta DPSave+2
lda devID
asl a
asl a
tax
lda DevIDPtrTbl+2,x
pha
sta Ptr+2
lda DevIDPtrTbl,x
pha
sta Ptr
lda [Ptr]
tax
lda DPSave
sta Ptr
lda DPSave+2
sta Ptr+2
txa
bra GD06
Done ldx TableIndex ;zero length bytes signals
stz DevNameTbl,x ; end of table entries
rts
;................................................................
;
; GetDevices data:
;
DPSave ds 4 ;save area for direct page data
TableIndex ds 2 ;index to device name/info tables
StrLen ds 4 ;number of bytes in target string
NoVolStr str '[ Volume not found ]'
DevIDTxtTbl anop ;table of device ID number definitions
ID00 str '[ Apple 5.25 drive ]'
ID01 str '[ Profile 5 MB hard drive ]'
ID02 str '[ Profile 10 MB hard drive ]'
ID03 str '[ Apple 3.5 drive ]'
ID04 str '[ SCSI ]'
ID05 str '[ SCSI hard disk ]'
ID06 str '[ SCSI tape drive ]'
ID07 str '[ SCSI CD ROM ]'
ID08 str '[ SCSI printer ]'
ID09 str '[ Serial modem ]'
ID10 str '[ Console driver ]'
ID11 str '[ Serial printer ]'
ID12 str '[ Serial LaserWriter ]'
ID13 str '[ AppleTalk LaserWriter ]'
ID14 str '[ RAM disk ]'
ID15 str '[ ROM disk ]'
ID16 str '[ File server ]'
ID17 str '[ Reserved ]'
ID18 str '[ AppleDesktop bus ]'
ID19 str '[ Generic hard disk ]'
ID20 str '[ Generic floppy disk ]'
ID21 str '[ Generic tape drive ]'
ID22 str '[ Generic char device driver ]'
ID23 str '[ MFM-encoded disk drive ]'
ID24 str '[ Generic AppleTalk network ]'
ID25 str '[ Sequential access device ]'
ID26 str '[ SCSI scanner ]'
ID27 str '[ Other scanner ]'
ID28 str '[ LaserWriter SC ]'
ID29 str '[ AppleTalk main driver ]'
ID30 str '[ AppleTalk file server ]'
ID31 str '[ AppleTalk RPM driver ]'
DevIDPtrTbl anop ;table of ptrs to device ID number definitions
dc a4'ID00,ID01,ID02,ID03,ID04,ID05,ID06,ID07'
dc a4'ID08,ID09,ID10,ID11,ID12,ID13,ID14,ID15'
dc a4'ID16,ID17,ID18,ID19,ID20,ID21,ID22,ID23'
dc a4'ID24,ID25,ID26,ID27,ID28,ID29,ID30,ID31'
end
*****************************************************************
*
SetWindSize start
*
* Calculate window size:
*
*****************************************************************
using Globals
stz EntryWidT1 ;zero variables
stz EntryWidT2
stz XSave
stz EntryNum
SW01 ldx XSave ;get index to table entries
lda DevNameTbl,x ;get length byte in device name table
beq SW06 ;no more table entries
inc EntryNum ;bump entry counter
ldy #^DevNameTbl ;get width of device name table entry
clc
txa
adc #DevNameTbl
tax
bcc SW02
iny
SW02 pha
phy
phx
_StringWidth
pla
cmp EntryWidT1 ;save widest string in device name table
bcc SW03
sta EntryWidT1
SW03 ldy #^DevInfoTbl ;get width of device info table entry
clc
lda XSave
adc #DevInfoTbl
tax
bcc SW04
iny
SW04 pha
phy
phx
_StringWidth
pla
cmp EntryWidT2 ;save widest string in device info table
bcc SW05
sta EntryWidT2
SW05 clc ;bump index to next table entries
lda XSave
adc #32
sta XSave
bra SW01
SW06 lda #30+5+5 ;set bottom window coordinate
clc ; (30=top, 5=top and bottom margins)
SW07 adc #9 ; (9=pixels per row)
dec EntryNum
bne SW07
sta wSize+4
clc ;set right window coordinate
lda EntryWidT1 ; and start of 2nd column
adc #30*2 ; (30=margins and space between columns)
sta Col2Left
adc EntryWidT2
adc #30
sta wSize+6
rts
;................................................................
;
; SetWindSize data:
;
EntryWidT1 ds 2 ;widest entry in device name table
EntryWidT2 ds 2 ;widest entry in device info table
EntryNum ds 2 ;number of table entries
end
*****************************************************************
*
ShowDevices start
*
* Display device information:
*
*****************************************************************
using Globals
_GetPrefixGS PfxParm ;get current prefix zero
bcc SD01 ;no error
dc h'00' ;crash (should never come here)
SD01 lda #5 ;leave 5-pixel space on top of window
sta v
stz XSave ;zero table index save location
SD02 ldx XSave ;get index to table entry
lda DevNameTbl,x ;get length byte of P-string in table
and #$FF
bne SD03 ;more table entries
rts ;no more table entries so exit
SD03 clc ;bump vertical coordinate to next line
lda v ; (9=pixels per line)
adc #9
sta v
PushWord CheckPosn ;move pen to check mark position
PushWord v
_MoveTo
jsl CheckCurDev ;check for currently active device
bcc SD04 ;present entry is active device
PushWord #$20 ;place space in front of entry if
bra SD05 ; it represents inactive device
SD04 PushWord #$12 ;check active device
SD05 _DrawChar
PushWord #$20 ;it takes 2 spaces to wipe
_DrawChar ; out 1 check mark
PushWord Col1Left ;move pen to 1st column coordinates
PushWord v
_MoveTo
ldy #^DevNameTbl ;display name of device
clc
lda XSave
adc #DevNameTbl
phy
pha
_DrawString
PushWord Col2Left ;move pen to 2nd column coordinates
PushWord v
_MoveTo
ldy #^DevInfoTbl ;display pathname or device description
clc
lda XSave
adc #DevInfoTbl
phy
pha
_DrawString
clc ;set index to next table entry
lda XSave
adc #32
sta XSave
brl SD02 ;loop back for another entry
;................................................................
;
; Check for currently active device:
;
; Exit: carry clear = active device, carry set = inactive device.
;
CheckCurDev ldx XSave
lda DevInfoTbl,x ;match volume name of block device with
and #$FF ; volume name of current prefix
tay ; -index GetPrefix buffer
clc
adc XSave
tax ; -index device info table
shortm
lda pfxNameStr+2,y
cmp #':'
bne NotCurDev
CCD01 dex
dey
beq GotCurDev
lda pfxNameStr+2,y
cmp #$60 ; -ensure upper case comparisons
bcc CCD02
and #$DF
CCD02 cmp DevInfoTbl+1,x
beq CCD01
NotCurDev longm ;no match means that present table entry
sec ; is not the currently active device
rtl
GotCurDev longm ;match means that present table entry
clc ; is the currently active device
rtl
;................................................................
;
; ShowDevices data:
;
v ds 2 ;vertical drawing position
end
*****************************************************************
*
Globals data
*
* Global data:
*
*****************************************************************
OpenFlag ds 2 ;open flag: NE=open, EQ=closed
WindowPtr ds 4 ;ptr to NDA window's GrafPort
XSave ds 2 ;value of table entry index
CheckPosn dc i2'15' ;position of check mark (active device)
Col1Left dc i2'30' ;left margin of column 1
Col2Left ds 2 ;left margin of column 2
DevNameTbl anop ;device name table
ds 32*16+2 ;max name size=32 bytes, max entries=16
DevInfoTbl anop ;device pathname/description table
ds 32*16 ;max entry size=32 bytes, max entries=16
WindowRec anop ;parameter list for NDA window
dc i2'wRecEnd-WindowRec' ;byte size of table
dc i2'%1100000010100000' ;description of window frame
dc i4'wTitle' ;ptr to title string
dc i4'0' ;reference constant
dc i2'0,0,0,0' ;zoom size
dc i4'wColorTable' ;ptr to color table
dc i2'0,0' ;offset of content area from data area
dc i2'0,0' ;height and width of data area
dc i2'0,0' ;grow height and width
dc i2'0,0' ;arrow scroll vert and horiz
dc i2'0,0' ;page scroll vert and horiz
dc i4'0' ;info bar reference constant
dc i2'0' ;info bar height
dc i4'0' ;ptr to frame definition procedure
dc i4'0' ;ptr to info bar defProc
dc i4'0' ;ptr to content update defProc
wSize dc i2'30,20,170,600' ;coordinates of window (T,L,B,R)
dc i4'-1' ;plane (front)
dc i4'0' ;ptr to memory (handled by Memory Mgr)
wRecEnd anop
wTitle str ' System Devices '
wColorTable anop ;color table for NDA window
dc i2'$0000' ;frame
dc i2'$0F0F' ;title string and inactive title bar
dc i2'$0144' ;active title bar
dc i2'$0000' ;grow box and alert's middle outline
dc i2'$0000' ;info bar and alert's inside outline
PfxParm anop ;GetPrefix parameter list (GS/OS class 1)
dc i2'2' ;pCount = 2
dc i2'0' ;prefix number zero
dc i4'pfxBuf' ;ptr to prefix result buffer
DInfoParm anop ;DInfo parameter list (GS/OS class 1)
dc i2'8' ;pCount = 8
devNum dc i2'0' ;device number
dc i4'devNameBuf' ;ptr to device name result buffer
charistics dc i2'0' ;characteristics of device
dc i4'0' ;total blocks on block device
dc i2'0' ;slot number
dc i2'0' ;unit number
dc i2'0' ;version of device driver
devID dc i2'0' ;device ID
VolumeParm anop ;Volume parameter list (GS/OS class 1)
dc i2'2' ;pCount = 2
dc i4'devNameStr' ;device name input string
dc i4'volNameBuf' ;ptr to volume name result buffer
devNameBuf anop ;device name result buffer
dc i2'35' ;buffer size word
devNameStr ds 2+31 ;string length word + name chars
volNameBuf anop ;volume name result buffer
dc i2'21' ;buffer size word
volNameStr ds 2+17 ;string length word + name chars
pfxBuf anop ;prefix zero result buffer
dc i2'70' ;buffer size word
pfxNameStr ds 2+66 ;string length word + name chars
end